
#ifndef _CLIB_LINKED_LIST
#define _CLIB_LINKED_LIST

typedef struct Node {
  void * value;
  struct Node * next;
} Node;

typedef struct LinkedList {
  int size;
  Node * head;
  Node * tail;
} LinkedList;


/* Interface for Linked List in C */

/* Call this each time you want to make a new linked list */
extern LinkedList * initialize() ;

/* Free all associated memory with the linked list */
extern void ll_free(LinkedList * ll);



/* Insert a new item of value value into the linked list at idx */
extern void ll_insert(LinkedList * ll, void * value, int idx) ;

/* Insert a new item of value value into the front of the linked list */
extern void ll_push(LinkedList * ll, void * value) ;

/* Insert a new item of value value into the back of the linked list */
extern void ll_append(LinkedList * ll, void * value) ;

/* Remove an item from the linked list at index idx. 
   Returns the value removed */
extern void * ll_remove(LinkedList * ll, int idx);

/* Get the value at a particular index */
extern void * ll_get(LinkedList * ll, int idx);

/* Get the number of items in the linked list */
extern int ll_size(LinkedList * ll);

/* Check if the linked list is empty or not. 
   Returns 1 if list is empty and 0 if not.
*/
extern int ll_isEmpty(LinkedList * ll);


/* Debug function to print the contents of the linked list */
extern void ll_print(LinkedList * ll);
    

#endif
